package com.zzsy.carosshopprojects.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.king.base.adapter.ViewHolderRecyclerAdapter;
import com.king.base.adapter.holder.ViewHolder;
import com.yatoooon.screenadaptation.ScreenAdapterTools;
import com.zzsy.carosshopprojects.R;
import com.zzsy.carosshopprojects.bean.ResterPostionBeans;
import com.zzsy.carosshopprojects.util.ViewBgUtil;

import java.util.List;

public class RegsterMoneyGridAdapter extends ViewHolderRecyclerAdapter<ResterPostionBeans> {
    private int pos = -1;

    public RegsterMoneyGridAdapter(Context context, List<ResterPostionBeans> listData, int layoutId) {
        super(context, listData, layoutId);
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.adapter_regster_money, null);
        ScreenAdapterTools.getInstance().loadView(view);
        return view;
    }

    @Override
    public void bindViewDatas(ViewHolder helper, ResterPostionBeans bean, int positions) {
        String number = bean.getAmountStr();
        String content = "￥" + number;
     //   SpannableString spannableString = StringUtils.setFontSizeSp(getContext(), content, 1, number.length() + 1, 20);
        TextView priceChb = helper.getView(R.id.item_price_btn);
        priceChb.setText(content);
        if (pos == positions) {
           // priceChb.setBackground(getContext().getResources().getDrawable(R.drawable.btn_jb));
            priceChb.setTextColor(getContext().getResources().getColor(R.color.colorPrimary));
            priceChb.setBackground(ViewBgUtil.setWidthBg(10,3,Color.parseColor("#FFFFFF"),Color.parseColor("#FF6900")));
        } else {
//            priceChb.setBackground(getContext().getResources().getDrawable(R.drawable.shape_select_oils_q));
//            priceChb.setTextColor(getContext().getResources().getColor(R.color.end_color_jb));
            priceChb.setTextColor(getContext().getResources().getColor(R.color.fonts_text));
            priceChb.setBackground(ViewBgUtil.setWidthBg(10,3,Color.parseColor("#FFFFFF"),Color.parseColor("#E5E5E5")));
        }

    }

    public void setPostion(int p) {
        pos = p;
        notifyDataSetChanged();
    }
}
